package com.baofu.paycore.service.factory.impl;

import com.baofu.paycore.manager.model.PayBO;
import com.baofu.paycore.service.facade.model.PayBaseDTO;
import com.baofu.paycore.service.factory.OrderFactory;
import com.baofu.paycore.service.factory.PayBaseFactory;
import com.baofu.paycore.service.processor.PayBaseProcessor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

/**
 * 消费单 组装工厂类
 *
 * <p/>
 *      1、组装支付模型
 * </p>
 * User: LZQ Date: 2016/04/20  Version: 1.0
 */
@Slf4j
@Service
public class ConsumeFactoryImpl extends PayBaseFactory implements OrderFactory {

    /**
     * 主单处理器
     */
    @Resource(name = "consumeProcessor")
    private PayBaseProcessor commonProcessor;

    /**
     * 资金单处理器
     */
    @Resource(name = "consumeFundProcessor")
    private PayBaseProcessor fundProcessor;

    @PostConstruct
    public void init(){
        processor.add(commonProcessor);
        processor.add(fundProcessor);
    }

    /**
     * 组装支付模型
     *
     * @param payBaseDTO 请求对象
     * @return 支付模型
     */
    @Override
    public PayBO build(PayBaseDTO payBaseDTO) {
        PayBO payBO = new PayBO();
        super.buildBO(payBO,payBaseDTO);
        log.debug("支付组装参数:{}", payBO);
        return payBO;
    }

}
